Run with Clamav - SquidClamav
2011/03/21 |
Install SquidClamav and Configure Proxy Server in order to scan download files to protect from virus.
Install Clamav first.
|
|
[1] | Install Clamd |
[root@lan ~]# /etc/rc.d/init.d/clamd start Starting Clam AntiVirus Daemon: [ OK ] [root@lan ~]# chkconfig clamd on
|
[2] | Install c-icap |
[root@lan ~]# wget http://ftp.jaist.ac.jp/pub/sourceforge/c/project/c-/c-icap/c-icap/0.1.x/c_icap-0.1.6.tar.gz [root@lan ~]# tar zxvf c_icap-0.1.6.tar.gz [root@lan ~]# cd c_icap-0.1.6 [root@lan c_icap-0.1.6]# ./configure [root@lan c_icap-0.1.6]# [root@lan c_icap-0.1.6]# make install [root@lan c_icap-0.1.6]# [root@lan ~]# cp /usr/local/etc/c-icap.conf /etc
[root@lan ~]#
vi /etc/c-icap.conf # line 140: change admin address ServerAdmin root@srv.world
# line 149: change to your server name ServerName lan.srv.world
# line 497: add Service squidclamav squidclamav.so
[root@lan ~]#
vi /etc/rc.d/init.d/c-icap # create init script #!/bin/bash # c-icap: Start/Stop c-icap # chkconfig: - 70 30 # description: c-icap is an implementation of an ICAP server. # processname: c-icap # pidfile: /var/run/c-icap/c-icap.pid . /etc/rc.d/init.d/functions . /etc/sysconfig/network CONFIG_FILE=/etc/c-icap.conf PID_DIR=/var/run/c-icap RETVAL=0 start() { echo -n $"Starting c-icap: " daemon /usr/local/bin/c-icap -f $CONFIG_FILE RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/c-icap return $RETVAL } stop() { echo -n $"Stopping c-icap: " killproc c-icap rm -f /var/run/c-icap/c-icap.ctl RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $PID_DIR/c-icap.pid /var/lock/subsys/c-icap return $RETVAL } case "$1" in start) start ;; stop) stop ;; status) status c-icap ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit $? chmod 755 /etc/rc.d/init.d/c-icap |
[3] | Install SquidClamav ( Download latest version of it from the following link ) http://sourceforge.net/projects/squidclamav/files/squidclamav/ |
[root@lan ~]# wget http://ftp.jaist.ac.jp/pub/sourceforge/s/project/sq/squidclamav/squidclamav/6.2/squidclamav-6.2.tar.gz [root@lan ~]# tar zxvf squidclamav-6.2.tar.gz [root@lan ~]# cd squidclamav-6.2 [root@lan squidclamav-6.2]# ./configure [root@lan squidclamav-6.2]# [root@lan squidclamav-6.2]# make install [root@lan squidclamav-6.2]#
[root@lan ~]#
vi /etc/squidclamav.conf # line 17: change( destination URL for redirect. Create it first ) redirect http://www.srv.world/error.html
# line 25: change( same with clamd ) clamd_local /var/run/clamav/clamd.sock
/etc/rc.d/init.d/c-icap start Starting c-icap: [ OK ] [root@lan ~]# chkconfig --add /etc/rc.d/init.d/c-icap [root@lan ~]# chkconfig c-icap on |
[4] | Configure Squid |
[root@lan ~]#
vi /etc/squid/squid.conf # add at the last line
icap_enable on
icap_send_client_ip on icap_send_client_username on icap_client_username_header X-Authenticated-User icap_service service_req reqmod_precache bypass=1 icap://127.0.0.1:1344/squidclamav adaptation_access service_req allow all icap_service service_resp respmod_precache bypass=1 icap://127.0.0.1:1344/squidclamav adaptation_access service_resp allow all /etc/rc.d/init.d/squid restart Stopping squid: ................[ OK ] Starting squid: .[ OK ] |
[5] | Try to access to a page that has trial virus from here. http://www.eicar.org/anti_virus_test_file.htm Click 'eicar.com' and rty to download it. Then, the error page that is set in the config of squidclamav. Virus is blocked normally. |